/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.maze.behaviours;

import java.util.Random;
import org.maze.Maze;
import org.maze.individual.Individual;

/**
 *
 * @author Thomas
 */
public class SimpleCrossBehaviour implements ICrossBehaviour{
    private static Random rand = new Random();

    public byte[][] cross(Individual father, Individual mother) {
        byte[] m = mother.getGenome();
        byte[] f = father.getGenome();
        byte[] child = new byte[Maze.SIZE*Maze.SIZE];
        byte[] child2 = new byte[Maze.SIZE*Maze.SIZE];


        for(int i=0; i<child.length; i++){
            int rd = rand.nextInt(2);
            if(rd==0){
                child[i]=m[i];
                child2[i]=f[i];
            }else{
               child[i]=f[i];
               child2[i]=m[i];
            }
                
        }
        byte[][] results = new byte[2][];
        results[0]=child;
        results[1]=child2;
        return results;
    }

}
